package com.edu.bean;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.util.Date;

public class User {
    private int userId;

    @NotNull(message = "用户名不能为空")
    @Length(min = 6,max = 10,message = "用户名应当在6-10位之间")
    private String userName;

    @NotNull(message = "密码不能为空")
    @Length(min = 6,max = 10,message = "密码应当在6-10位之间")
    private String userPass;

    @Range(min = 1,max = 200,message = "年龄过大或过小")
    private int userAge;

    @Pattern(regexp = "^[男女]$",message = "人妖？？")
    private String userSex;

    @Past(message = "请输入一个过去的时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = {"yyyy/MM/dd","yyyy年MM月dd日"})
    private Date userBirthday;

    @DecimalMin(value = "1800.00",message = "最低薪资应当在1800+")
    @NumberFormat(style = NumberFormat.Style.CURRENCY,pattern = "￥#,###.##")
    private double userMoney;


    @NumberFormat(style = NumberFormat.Style.PERCENT)
    private double userWork;

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPass() {
        return userPass;
    }

    public void setUserPass(String userPass) {
        this.userPass = userPass;
    }

    public int getUserAge() {
        return userAge;
    }

    public void setUserAge(int userAge) {
        this.userAge = userAge;
    }

    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    public Date getUserBirthday() {
        return userBirthday;
    }

    public void setUserBirthday(Date userBirthday) {
        this.userBirthday = userBirthday;
    }

    public double getUserMoney() {
        return userMoney;
    }

    public void setUserMoney(double userMoney) {
        this.userMoney = userMoney;
    }

    public double getUserWork() {
        return userWork;
    }

    public void setUserWork(double userWork) {
        this.userWork = userWork;
    }

    public User() {
    }

    public User(int userId, String userName, String userPass, int userAge, String userSex, Date userBirthday, double userMoney, double userWork) {
        this.userId = userId;
        this.userName = userName;
        this.userPass = userPass;
        this.userAge = userAge;
        this.userSex = userSex;
        this.userBirthday = userBirthday;
        this.userMoney = userMoney;
        this.userWork = userWork;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", userPass='" + userPass + '\'' +
                ", userAge=" + userAge +
                ", userSex='" + userSex + '\'' +
                ", userBirthday=" + userBirthday +
                ", userMoney=" + userMoney +
                ", userWork=" + userWork +
                '}';
    }
}
